//
//  FMLayoutExtenstions.swift
//  FMLayoutKit
//
//  Created by CoderFM on 2024/4/21.
//

import Foundation

//public extension FMLayoutBaseSection {
//    @discardableResult
//    func addHeader<HeaderType: UICollectionReusableView>(height: CGFloat, itemSpace: CGFloat = 0, isNib: Bool = false, reuseId: String? = nil, config: ((HeaderType) -> Void)? = nil) -> Self {
//        let header = reuseId != nil ? FMLayoutHeader.elementSize(height, viewClass: HeaderType.self, isNib: isNib, reuseIdentifier: reuseId!) : FMLayoutHeader.elementSize(height, viewClass: HeaderType.self, isNib: isNib)
//        header.lastMargin = itemSpace
//        configureHeaderData = { (section, headerView) in
//            if let headerV = headerView as? HeaderType {
//                config?(headerV)
//            }
//        }
//        self.header = header
//        return self
//    }
//    
//    @discardableResult
//    func addFooter<FooterType: UICollectionReusableView>(height: CGFloat, autoHeight: Bool = false, itemSpace: CGFloat = 0, isNib: Bool = false, reuseId: String? = nil, config: ((FooterType) -> Void)? = nil) -> Self {
//        let footer = reuseId != nil ? FMLayoutFooter.elementSize(height, viewClass: FooterType.self, isNib: isNib, reuseIdentifier: reuseId!) : FMLayoutFooter.elementSize(height, viewClass: FooterType.self, isNib: isNib)
//        footer.topMargin = itemSpace
//        footer.autoHeight = autoHeight
//        configureFooterData = { (section, footerView) in
//            if let footerV = footerView as? FooterType {
//                config?(footerV)
//            }
//        }
//        self.footer = footer
//        return self
//    }
//    
//    @discardableResult
//    func addBg<BgType: UICollectionReusableView>(top: CGFloat = 0, left: CGFloat = 0, right: CGFloat = 0, bottom: CGFloat = 0,isNib: Bool = false,  reuseId: String? = nil, config: ((BgType) -> Void)? = nil) -> Self {
//        let bg = reuseId != nil ? FMLayoutBackground(viewClass: BgType.self, isNib: isNib, reuseIdentifier: reuseId!) : FMLayoutBackground(viewClass: BgType.self, isNib: isNib)
//        bg.inset = UIEdgeInsets(top: top, left: left, bottom: bottom, right: right)
//        bg.zIndex = .backOfItem
//        configureBg = { (section, bgView) in
//            if let bgV = bgView as? BgType {
//                config?(bgV)
//            }
//        }
//        self.background = bg
//        return self
//    }
//    
//    @discardableResult
//    func addItems(_ items: [Any]) -> Self {
//        itemDatas.addObjects(from: items)
//        return self
//    }
//}
//
//public extension FMLayoutBaseSection {
//    static func baseSection<CellType: UICollectionViewCell, DateType>(top: CGFloat = 0, left: CGFloat = 0, right: CGFloat = 0, bottom: CGFloat = 0, itemSpace: CGFloat = 0, lineSpace: CGFloat = 0, column: Int = 1, initData: [DateType] = [], config: ((CellType, DateType, Int) -> Void)? = nil, click: ((Int, DateType) -> Void)? = nil) -> Self {
//        let section = self.init(sectionInset: UIEdgeInsets(top: top, left: left, bottom: bottom, right: right), itemSpace: itemSpace, lineSpace: lineSpace, column: column)
//        section.itemDatas = NSMutableArray(array: initData)
//        section.configureCellData = { (section, cell, item) in
//            if let rCell = cell as? CellType, let itemData = section.itemDatas[item] as? DateType {
//                config?(rCell, itemData, item)
//            }
//        }
//        section.clickCellBlock = { (section, item) in
//            if let itemData = section.itemDatas[item] as? DateType, let click = click {
//                click(item, itemData)
//            }
//        }
//        return section
//    }
//}
//
//public extension FMLayoutFixedSection {
//    static func section<CellType: UICollectionViewCell, DateType>(top: CGFloat = 0, left: CGFloat = 0, right: CGFloat = 0, bottom: CGFloat = 0, itemSpace: CGFloat = 0, lineSpace: CGFloat = 0, column: Int = 1, itemSize: CGSize, initData: [DateType] = [], isNib: Bool = false, reuseId: String? = nil, config: ((CellType, DateType, Int) -> Void)? = nil, click: ((Int, DateType) -> Void)? = nil) -> Self {
//        let section = self.baseSection(top: top, left: left, right: right, bottom: bottom, itemSpace: itemSpace, lineSpace: lineSpace, column: column, initData: initData, config: config, click: click)
//        section.itemSize = itemSize
//        if let reuseId = reuseId {
//            section.cellElement = FMLayoutElement(viewClass: CellType.self, isNib: isNib, reuseIdentifier: reuseId)
//        } else {
//            section.cellElement = FMLayoutElement(viewClass: CellType.self, isNib: isNib)
//        }
//        return section
//    }
//}
//
//public extension FMLayoutDynamicSection {
//    static func section<CellType: UICollectionViewCell, DateType>(top: CGFloat = 0, left: CGFloat = 0, right: CGFloat = 0, bottom: CGFloat = 0, itemSpace: CGFloat = 0, lineSpace: CGFloat = 0, column: Int = 1, itemWidth: CGFloat, autoHeight: Bool = false, otherHeight: ((Int, DateType) -> CGFloat)? = nil, initData: [DateType] = [], isNib: Bool = false, reuseId: String? = nil, config: ((CellType, DateType, Int) -> Void)? = nil,  click: ((Int, DateType) -> Void)? = nil) -> Self {
//        let section = self.baseSection(top: top, left: left, right: right, bottom: bottom, itemSpace: itemSpace, lineSpace: lineSpace, initData: initData, config: config, click: click)
//        section.cellFixedSize = itemWidth
//        section.autoHeightFixedWidth = autoHeight
//        if (!autoHeight) {
//            section.otherBlock = { (section, item) in
//                if let otherHeight = otherHeight, let bSection = section as? FMLayoutBaseSection, let data = bSection.itemDatas[item] as? DateType {
//                    return otherHeight(item, data)
//                }
//                return 0
//            }
//        }
//        if let reuseId = reuseId {
//            section.cellElement = FMLayoutElement(viewClass: CellType.self, isNib: isNib, reuseIdentifier: reuseId)
//        } else {
//            section.cellElement = FMLayoutElement(viewClass: CellType.self, isNib: isNib)
//        }
//        section.configureCellData = section.configureCellData
//        return section
//    }
//}
